package thread;

/**
 * @author Jonny Long
 * @date 2021/3/28 9:56
 */
public class Join {
    static class ThreadA implements Runnable {
        @Override
        public void run() {
            try {
                System.out.println("我是子线程，我先睡一秒");
                Thread.sleep(3000);
                System.out.println("我是子线程，我睡完了一秒");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        try {
            Thread thread = new Thread(new ThreadA());
            thread.start();
            thread.join();
            System.out.println("如果不加join方法，我会先被打出来，加了就不一样了");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
